<template>
  <div>
  <div style="float: right;width: 375px;height: 40px;text-align: right;font-family: 华文琥珀">帮助</div>
  <div class="huanying">欢迎登录美团</div>
    <div class="login">
      <van-form @submit="onSubmit">
        <van-field
          v-model="user.phone"
          name="用户名"
          label="手机号"
          placeholder="请输入手机号"
          :rules="[{ required: true, message: '' }]"
        style="margin-left: 0"/>
        <van-field
          v-model="user.password"
          type="password"
          name="密码"
          label="密码"
          placeholder=""
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <div style="margin: 16px">
          <van-button round block type="info" native-type="submit" style="color: black;font-weight: bold">登录</van-button>
        </div>
      </van-form>
      <router-link to="/login1"><div style="text-align: left;width: 100px;float: left" @click="">验证码登录</div></router-link>
      <div style="float: right">遇到问题</div>
    </div>

  </div>

</template>

<script>

  import axios from 'axios'
  axios.defaults.withCredentials=true
    export default {
        name: "login",
      data(){
        return {
        user:{
          phone:'',
          password:''
        }
        };
      },
      methods: {
        onSubmit(values) {
          // axios("http://localhost/user/token").then(res=>{
          //
          // })
          axios.post('api/user/login',this.user).then(res=>{
            sessionStorage.setItem("phone",this.user.phone);
            this.$cookie.set("token",res.data.data);
            this.$router.push("/");
          })
        },
      }
    }
</script>



<style scoped>
.login{
  margin-top: 50px;
  text-align: center;
}
  .huanying{
  font-weight: bold;
    font-size: 30px;
    margin-left: 10px;
    padding: 0;
  }


</style>
